<extend name="Base/common"/>
<!--<script type="text/javascript" src="/SG_Shopwechat/Public/Home/js/iscroll.js"></script>-->
<block name="TITLE"><title>采购申请</title></block>
<block name="body" >
    <header data-am-widget="header" class="am-header am-header-default am-header-fixed">
        <div class="am-header-left am-header-nav">
            <a href="{:U('Purchase/index')}" class="">
                <i class="am-header-icon am-icon-home" style="font-size: 40px;"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="">
                &nbsp;{$title}
            </a>
        </h1>
    </header>
    <body>

    <div class="" style="font-size: 15px;">
        <table class="am-table am-table-striped">
            <tr>
                <th>商品名</th>
                <td>{$pname}</td>
                <th>规格</th>
                <td>{$spec}</td>
            </tr>
            <tr>
                <th>往期价格</th>
                <td>{$oldprice}</td>
                <th>采购备注</th>
                <td>{$mark}</td>
            </tr>
        </table>
    </div>
    <empty name="list">
        暂时没有商品
        <else/>
        <table id="datatable" class="am-table am-table-striped " style="width:100%;font-size: 15px;">
            <thead style="">
                <tr>
                    <th>供货商</th>
                    <th>报价</th>
                    <th>备注</th>
                    <th class="">操作</th>
                </tr>
            </thead>
            <volist name="list" id="pro">
                <tr>
                    <td>{$pro.uid|get_provider_name}</td>
                    <td>{$pro.price}</td>
                    <td>{$pro.mark}</td>
                    <td class="am-text-left">
                        <if condition="$pro['have_see'] eq 0">
                            <a class="am-btn am-btn-warning am-btn-xs checkgood" data-id="{$pro.id}">验货</a>
                            <else/>
                            <a class="am-btn am-btn-primary am-btn-xs ">已验货</a>
                        </if>
                        <if condition="$pro['accept'] eq 0">
                            <a href="{:U('profinish')}&pid={$pro.pid}&batch={$pro.batch}&providerid={$pro.uid}" class="am-btn am-btn-danger am-btn-xs accept">接受报价</a>
                            <else/>
                            <a class="am-btn am-btn-primary am-btn-xs ">已接受</a>
                        </if>
                    </td>
                </tr>
            </volist>
        </table>
    </empty>
    </body>
</block>
<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script type="text/javascript">
        $("#datatable").dataTable({
            paging: false,
            searching: false,
            info:false,
            language: {
                search: "查询:",
                lengthMenu:    "每页显示 _MENU_ 条",
                info:           "当前  _START_ - _END_ 条，共 _TOTAL_ 条",
                paginate: {
                    first:      "第一页",
                    previous:   "上一页",
                    next:       "下一页",
                    last:       "最后一页"
                },
            }
        });
        $('.confirm').click(function(){
            if(confirm("请确认操作")){
            }else{
                return false;
            }
        });
        $('.checkgood').click(function(){
            var id = $(this).data('id');
            var url = '{:U('purchase/havesee')}';
            if(confirm("确认验货？")){
                $.ajax({
                    type: "POST",
                    url:url,
                    data:{id:id},
                    async: false,
                    error: function(request) {
                        alert(request);
                    },
                    success: function(data) {
                        if(data == 1||data == "1"){
                            window.location.reload();
                        }
                    }
                });
            }
        });
    </script>
</block>
